package com.wgj.android.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.provider.ContactsContract;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jiaai.xui.view.widget.tablayout.widget.MsgView;
import com.wgj.android.R;

/**
 * Created by Administrator on 2018/5/11.
 */

public class OrderClassItem extends LinearLayout {
    private View mView;
    private Context mContext;
    private MsgView msgView;
    private TextView tv_title;
    private ImageView im_icon;
    public OrderClassItem(Context context) {
        super(context);
    }

    public OrderClassItem(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public OrderClassItem(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mView= LayoutInflater.from(mContext).inflate(R.layout.order_class_item_view,null);
        msgView=mView.findViewById(R.id.msgNum);
        tv_title=mView.findViewById(R.id.title);
        im_icon=mView.findViewById(R.id.icon);
        addView(mView);
    }
    public void clear(){
       msgView.setText("");
       msgView.setVisibility(View.GONE);
    }
    public void setMsgNum(int num){
        msgView.setText(num+"");
        msgView.setVisibility(View.VISIBLE);
    }
    public void setTitle(String title, Drawable drawable){
        tv_title.setText(title);
        setImage(drawable);
    }
    private  void  setImage(Drawable drawable){
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        im_icon.setImageDrawable(drawable);
    }
}
